2 ==============================================================================
4 This file is part of the JUCE library - "Jules' Utility Class Extensions"
5 Copyright 2004-11 by Raw Material Software Ltd.
7 ------------------------------------------------------------------------------
9 JUCE can be redistributed and/or modified under the terms of the GNU General
10 Public License (Version 2), as published by the Free Software Foundation.
11 A copy of the license is included in the JUCE distribution, or can be found
12 online at www.gnu.org/licenses.
14 JUCE is distributed in the hope that it will be useful, but WITHOUT ANY
15 WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
16 A PARTICULAR PURPOSE. See the GNU General Public License for more details.
18 ------------------------------------------------------------------------------
20 To release a closed-source product which uses JUCE, commercial licenses are
21 available: visit www.rawmaterialsoftware.com/juce for more information.
23 ==============================================================================
26 #include "../jucer_Headers.h"
27 #include "jucer_PrefsPanel.h"
29 //==============================================================================
30 class MiscPage
: public Component
32 FilenameComponent
* templateDir
;
37 addAndMakeVisible (templateDir
38 = new FilenameComponent ("C++ template folder:",
39 StoredSettings::getInstance()->getTemplatesDir(),
45 "(select the directory containing template .cpp and .h files)"));
47 (new Label (String::empty
, templateDir
->getName()))->attachToComponent (templateDir
, true);
52 StoredSettings::getInstance()->setTemplatesDir (templateDir
->getCurrentFile());
59 templateDir
->setBounds (150, 16, getWidth() - 160, 22);
63 //==============================================================================
64 class AboutPage
: public Component
66 HyperlinkButton
* link
;
68 TextLayout text1
, text2
;
73 logo
= ImageCache::getFromMemory (BinaryData::jules_jpg
, BinaryData::jules_jpgSize
);
75 text1
.appendText ("Programmer Julian Storer, seen here demonstrating a beard designed to "
76 "gain approval from the Linux programming community. Each hair of the beard "
77 "represents one line of source code from the ", Font (13.0f
));
78 text1
.appendText ("Jucer", Font (13.0f
, Font::bold
));
79 text1
.appendText (" component design tool.", Font (13.0f
));
81 text2
.appendText ("Jucer v" + JUCEApplication::getInstance()->getApplicationVersion()
82 + ", " + SystemStats::getJUCEVersion(), Font (14.0f
, Font::bold
));
84 addAndMakeVisible (link
= new HyperlinkButton ("www.rawmaterialsoftware.com/juce",
85 URL ("http://www.rawmaterialsoftware.com/juce")));
86 link
->setFont (Font (10.0f
, Font::bold
| Font::underlined
), true);
94 void paint (Graphics
& g
)
96 g
.fillAll (Colour (0xffebebeb));
97 g
.drawImageWithin (logo
, 0, 4, getWidth(), getHeight() - 134,
98 RectanglePlacement::centred
| RectanglePlacement::onlyReduceInSize
,
101 text1
.drawWithin (g
, 0, getHeight() - 120, getWidth(), 100, Justification::centredTop
);
102 text2
.drawWithin (g
, 0, getHeight() - 50, getWidth(), 100, Justification::centredTop
);
107 text1
.layout (getWidth() - 24, Justification::topLeft
, false);
108 text2
.layout (getWidth() - 24, Justification::centred
, false);
110 link
->setSize (100, 22);
111 link
->changeWidthToFitText();
112 link
->setTopLeftPosition ((getWidth() - link
->getWidth()) / 2, getHeight() - link
->getHeight() - 10);
117 //==============================================================================
118 static const char* miscPage
= "Misc";
119 static const char* keysPage
= "Keys";
120 static const char* aboutPage
= "About";
122 class PrefsTabComp
: public PreferencesPanel
127 addSettingsPage (miscPage
, BinaryData::prefs_misc_png
, BinaryData::prefs_misc_pngSize
);
128 addSettingsPage (keysPage
, BinaryData::prefs_keys_png
, BinaryData::prefs_keys_pngSize
);
129 addSettingsPage (aboutPage
, BinaryData::prefs_about_png
, BinaryData::prefs_about_pngSize
);
134 StoredSettings::getInstance()->flush();
137 Component
* createComponentForPage (const String
& pageName
)
139 if (pageName
== miscPage
)
141 return new MiscPage();
143 else if (pageName
== keysPage
)
145 return new KeyMappingEditorComponent (*commandManager
->getKeyMappings(), true);
147 else if (pageName
== aboutPage
)
149 return new AboutPage();
152 return new Component();
156 //==============================================================================
157 static String prefsWindowPos
;
159 PrefsPanel::PrefsPanel()
160 : DialogWindow ("Jucer Preferences", Colour::greyLevel (0.92f
), true)
162 PrefsTabComp
* const p
= new PrefsTabComp();
163 p
->setSize (456, 510);
165 setContentOwned (p
, true);
167 if (! restoreWindowStateFromString (prefsWindowPos
))
168 centreAroundComponent (0, getWidth(), getHeight());
170 setResizable (true, true);
171 setResizeLimits (400, 400, 1000, 800);
174 PrefsPanel::~PrefsPanel()
176 prefsWindowPos
= getWindowStateAsString();
179 void PrefsPanel::closeButtonPressed()
184 void PrefsPanel::show()